<!doctype html>
<html>
<head>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">
<title>优惠劵</title>
<link href="css/style.css" rel="stylesheet" type="text/css">
<link href="css/Pager.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="js/jquery.pager.js"></script>
<script type="text/javascript" src="js/gbRst.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/utils.js"></script>
<script type="text/javascript" src="js/openId1.js"></script>
<script type="text/javascript" src="js/qmsk-1.2.js"></script>
<script type="text/javascript">
var _actId = getIdByName("id");//获得活动id
$(function(){
	if(IsEmpty(_actId)){
		alert("页面出错");
		return false;
	}
	//加载活动内容
	$.ajax({
		url:'../couponRule/find/id/'+_actId,
		type:'get',
		data:{},
		success:function(data){
		var dt = JSON.parse(data);
			if(dt.state==0){
				if(dt.result.len==0){
					alert("查看优惠劵出错")	
				}else{		
				$("#save_btn").show();
				$("#imageUrl").attr("src",getHtmlString(getHeadIndexValue(0, dt, "imageUrl")))
				$("#actName").html(getHtmlString(getHeadIndexValue(0, dt, "RuleName")))
				$("#beginTime").html(getHtmlString(getHeadIndexValue(0, dt, "EffectDate")).substring(0,10))
				$("#endTime").html(getHtmlString(getHeadIndexValue(0, dt, "UneffectDate")).substring(0,10))
				iframeHei(getHtmlString(getHeadIndexValue(0, dt, "indexURL")))
				}
			}else{
			alert("查看活动出错")	
			}
		}
	})

})
//参与活动
function addInfo(){
	if(IsEmpty(_actId)||IsEmpty(_openId)){
		alert("网页出错");
		return false;
	}else{
		$.ajax({
			url:'../memberConpBill/insert/getCoupon',
			data:{'openId':_openId,'id':_actId},
			type:'post',
			success:function(data){
			var dt = JSON.parse(data);
				if(dt.state==0){
					alert("获得一张优惠劵")
				}else{
					alert(dt.msg)
				}
			}
		})	
	}
	
	
}


function iframeHei(url){
	$.ajax({
		url:'../htmlUtils/find/getHtml',
		type:'get',
		data:{'htmlUrl':url},
		type:'post',
		success:function(data){
		var dt = JSON.parse(data);
			if(dt.state==0){
				var html = getHtmlString(getHeadIndexValue(0, dt, "htmlStr"))
				$("#content").append(html)
			}
		}
	})
}

//frame标签自适应高度
</script>
</head>

<body style="background:#ddd;">
<div class="wrapper">

    <div id="content" class="container">
    	<div class="actor">
        	<dl>
            	<dt><img id="imageUrl" src=""></dt>
                <dd><strong id="actName"></strong><p>有效时间：<span id="beginTime"></span>至<span id="endTime"></span></p></dd>
            </dl>
            <div class="give" style="margin:10px auto 0;"><input  id="save_btn" onclick="addInfo();" style="display: none;" type="button" class="btn" value="立即获取"></div>
        </div>
       
    </div>
</div>

</body>

</html>
